var 
gsAgent=navigator.userAgent.toLowerCase(),
gsAppVer=navigator.appVersion.toLowerCase(),
gsAppName=navigator.appName.toLowerCase(),
gbIsOpera=gsAgent.indexOf("opera")>-1,
gbIsKHTML=gsAgent.indexOf("khtml")>-1
||gsAgent.indexOf("konqueror")>-1||gsAgent.indexOf("applewebkit")>-1,
gbIsSafari=gsAgent.indexOf("applewebkit")>-1,
gbIsIE=(gsAgent.indexOf("compatible")>-1&&!gbIsOpera)
||gsAgent.indexOf("msie")>-1,
gbIsTT=gbIsIE?(gsAppVer.indexOf("tencenttraveler")!=-1?1:0):0,
gbIsFF=gsAgent.indexOf("gecko")>-1&&!gbIsKHTML,
gbIsNS=!gbIsIE&&!gbIsOpera&&!gbIsKHTML&&(gsAgent.indexOf("mozilla")==0)
&&(gsAppName=="netscape"),
gbIsAgentErr=!(gbIsOpera||gbIsKHTML||gbIsSafari||gbIsIE||gbIsTT
||gbIsFF||gbIsNS),
gbIsWin=gsAgent.indexOf("windows")>-1||gsAgent.indexOf("win32")>-1,
gbIsVista=gbIsWin&&(gsAgent.indexOf("nt 6.0")>-1||gsAgent.indexOf("windows vista")>-1),
gbIsWin7=gbIsWin&&gsAgent.indexOf("nt 6.1")>-1,
gbIsMac=gsAgent.indexOf("macintosh")>-1||gsAgent.indexOf("mac os x")>-1,
gbIsLinux=gsAgent.indexOf("linux")>-1,
gbIsAir=gsAgent.indexOf("adobeair")>-1,
gnIEVer=/MSIE (\d+.\d+);/i.test(gsAgent)&&parseFloat(RegExp["$1"]),
gsFFVer=/firefox\/((\d|\.)+)/i.test(gsAgent)&&RegExp["$1"],
gsSafariVer=/version\/((\d|\.)+)/i.test(gsAgent)&&RegExp["$1"],
gsChromeVer=/chrome\/((\d|\.)+)/i.test(gsAgent)&&RegExp["$1"],
aDc="_For_E_Built";

function checkCheckBoxs(bj,bN)
{
	var aG=bN||S("frm",getMainWin()),
	eJ=GelTags("input",aG),
	dC;
	for(var i=0,at=eJ.length;i<at;i++)
	{
		dC=eJ[i];
		if(dC.type=="checkbox"
			&&dC.name==bj
			&&dC.checked)
		{
			return true;
		}
	}
	return false;
}

function setListCheck(fE,rB)
{
	if(fE.type!="checkbox")
	{
		return;
	}
	if(rB==null)
	{
		rB=fE.checked;
	}
	else
	{
		fE.checked=rB;
	}
	var bt=fE.parentNode.parentNode;
	if(bt.tagName=="TR")
	{
		bt=bt.parentNode.parentNode;
	}
	var wx=bt.className;
	if(wx=="B")
	{
		wx=rB?"B":"";
	}
	else
	{
		wx=strReplace(wx," B","")+(rB?" B":"");
	}
	setClass(bt,wx);
	if(rB)
	{
		listMouseOut.call(bt);
	}
}

function doCheck(ae,aBW,aAy,ats)
{
	var aV=ae||window.event,
	aX=aBW||aV.srcElement||aV.target,
	aM=ats||getMainWin();
	if(!aX||!aM)
	{
		return;
	}
	if(aX.className=="one"||aX.className=="all")
	{
		CA(aX);
	}
	setListCheck(aX);
	if((aV&&aV.shiftKey||aAy)
		&&aM.gCurSelObj
		&&aM.gCurSelObj!=aX
		&&aX.checked==aM.gCurSelObj.checked)
	{
		var eJ=getTop().GelTags("input",aM.document),
		bP=0,
		at=eJ.length,
		dC;
		for(var i=0;i<at;i++)
		{
			dC=eJ[i];
			if(dC.type!="checkbox")
			{
				continue;
			}
			if((dC==aM.gCurSelObj
					||dC==aX)&&bP++==1)
			{
				break;
			}
			if(bP==1)
			{
				setListCheck(dC,aX.checked);
			}
		}
	}
	aM.gCurSelObj=aX;
}


function checkAll(Ml,bI)
{
	E(GelTags("input",bI),function(bD)
	{
		if(bD.name==Ml)
		{
			setListCheck(bD);
		}
		}
	);
}

function SG(vn,aAB)
{
	var bd=vn.className,
	dX=!/\bsts\b/i.test(bd);
	var	aY=GelTags("input",vn.parentNode)[0],
	Vy=aY&&aY.className,
	vY=(aAB?vn.parentNode.parentNode.parentNode:vn.parentNode).nextSibling;
	if(Vy=="one"||Vy=="all")
	{
		setClass(aY,dX?"one":"all");
	}
	setClass(vn,dX?bd.replace(/\bhts\b/i,"sts"):bd.replace(/\bsts\b/i,"hts"));
	if(vY.className!="toarea")
	{
		vY=vY.nextSibling;
	}
	if(vY.className!="toarea")
	{
		return;
	}
	return show(vY,dX);
}

function CA(vC)
{
	if(vC)
	{
		var wl=(vC.className=="all"
		?vC.parentNode.parentNode.parentNode.parentNode
		:vC.parentNode).nextSibling;
		if(wl.className!="toarea")
		{
			wl=wl.nextSibling;
		}
		if(wl.className=="toarea")
		{
			var awV=vC.checked;
			E(GelTags("input",wl),function(bD)
			{
				setListCheck(bD,awV);
			}
			);
		}
	}
}

function isShow(od,bI)
{
	return(getStyle((typeof(od)=="string"?S(od,bI):od),"display")||"none")
	!="none";
}

function show(od,hA,bI)
{
	var bt=(typeof(od)=="string"?S(od,bI):od);
	if(bt)
	{
		bt.style.display=(hA?"":"none");
	}
	else if(!bI&&typeof(od)=="string")
	{
	
	}
	return bt;
}
var Show=show;


function selectAll(Jl,bI)
{
	E(GelTags("input",S('list',bI)),function(dV)
	{
		dV.checked=Jl;
	}
	);
}
function listMouseOver(ae)
{
	if(this.className.indexOf(" B")==-1
		&&getStyle(this,"backgroundColor")!="#f3f3f3"
		&&this.getAttribute("colorchange")!="none")
	{
		this.style.backgroundColor="#f3f3f3";
	}
}

function listMouseOut(ae)
{
	if((!ae||!isObjContainTarget(this,ae.relatedTarget
		||ae.toElement))
	&&this.style.backgroundColor
	&&this.getAttribute("colorchange")!="none")
	{
		this.style.backgroundColor="";
	}
}

function listMouseEvent(aI)
{
	addEvent(aI,"mouseover",function(ae)
	{
		listMouseOver.call(aI,ae);
	}
	);
	addEvent(aI,"mouseout",function(ae)
	{
		listMouseOut.call(aI,ae);
	}
	);
}

function GetListMouseClick(aj)
{
	return function(ae)
	{
		ListMouseClick(ae,aj||window);
	}
}

function ListMouseClick(ae,aj)
{
	var aX,
	aV=ae||aj.event;
	if(!(aX=getEventTarget(aV)))
	{
		return;
	}
	if(aX.name=="mailid")
	{
		return doCheck(aV);
	}
	if(aX.className.indexOf("cir")==0)
	{
		var BX=GelTags("table",aX.parentNode.parentNode)[0]
		.parentNode.onclick.toString().split("{")[1]
		.split("}")[0].replace(/event/ig,"{shiftKey:true}");
		if(/\WRD/.test(BX))
		{
			return eval(BX);
		}
		else
		{
			BX=GelTags("table",aX.parentNode.parentNode)[0]
			.parentNode.onclick.toString().replace(/.*{/g,"")
			.replace(/}.*/g,"").replace(/event/ig,"{shiftKey:true}");
			return eval(BX);
		}
	}
	if(aX.parentNode.className.indexOf("pr")==0)
	{
		quickReadMail(aX.parentNode);
		return stopPropagation(aV);
	}
	if(/fg\x20fs1\x20*$/.test(aX.parentNode.className))
	{
		quickSetStar(aX.parentNode,GelTags("input",
		aX.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
		)[0].value,false,aj);
		return stopPropagation(aV);
	}
}

function listInitForComm(bl,aAp)
{
	var bd,
	fA=GelTags("div"),
	aIE=doCheck,
	sI,dW;
	bd=bl?bl:"M";
	for(var i=fA.length-1;i>=0;i--)
	{
		sI=fA[i];
		if(sI.className!=bd)
		{
			continue;
		}
		if(bl=="ft")
		{
			sI=GelTags("table",sI)[0];
		}
		dW=GelTags("input",sI)[0];
		if(!dW||dW.type!="checkbox")
		{
			continue;
		}
		dW.title="按住shift点击不同的勾选框 可方便快捷多选";
		addEvent(dW,"click",aIE);
		if(!aAp)
		{
			listMouseEvent(sI);
		}
	}
}


function getCheckBoxsInfo(bI,as)
{
	var az={index:[],zu:[]};
	E(GelTags("input",S('list',bI)),function(bD)
	{
		if(bD.title=="选中/取消选中")
		{
			az.allCheckBox=bD;
		}
		else if(bD.type=="checkbox"&&bD.name=="mailid"
			&&(as?bD.value==as:bD.checked))
		{
			var me=bD.value,
			dH=bD.parentNode;
			if(az[me])
			{
				me+="??2";
			}
			else
			{
				az.index.push(me);
			}
			while(dH.tagName.toUpperCase()!="TABLE")
			{
				dH=dH.parentNode;
			}
			var fO=dH.rows[0].cells,
			gU=fO[fO.length-1],
			Vj=GelTags("input",gU)[0],
			vy=GelTags("td",gU),
			BU=vy[0],
			kn=GelTags("table",gU),
			mQ,
			kr=[];
			for(var ah=0,at=kn.length;ah<at;ah++)
			{
				if(mQ=kn[ah].getAttribute("tagid"))
				{
					kr.push(mQ);
				}
			}
			az[me]={
				subunread:vy[1].className=="new_g"&&GelTags("b",vy[1]).length>0,
				unread:bD.getAttribute("unread")=="true",
				asy:BU.firstChild?htmlEncode(BU.firstChild.innerText||BU.firstChild.textContent):"",
				Gf:BU.title,
				moCheckBox:bD,
				moTable:dH,
				arZ:vy[1].className=="fg fs1"||vy[2].className=="fg fs1",
				asc:Vj&&Vj.className=="s1bg",
				oTagIds:kr
			};
			az.zu.push(me);
		}
	});
	return az;
}


function checkMail(ha)
{
	if(ha=="")
	{
		showError("添加的内容不能为空");
		return false;
	}
	
	if(!ha.match(/^[\.a-zA-Z0-9_=-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/))
	{
		showError("您输入的邮箱地址不正确，请重新输入");
		return false;
	}
	return true;
}


function alertBox(aA)
{
	confirmBox(extend({mode:"alert"},aA))
}

function hiddenMsg()
{
	if(getTop().gMsgBoxTimer)
	{
		getTop().clearInterval(getTop().gMsgBoxTimer);
		getTop().gMsgBoxTimer=null;
	}
	getTop().show("msgBoxDIV",false);
	getTop().showProcess(0);
}




function loadCssFile(kt,aup,gs)
{
	var bn=gs||document;
	if(aup)
	{
		for(var aPF=GelTags("link",bn),
				i=aPF.length-1;i>=0;i--)
		{
			if(aPF[i].href.indexOf(kt)!=-1)
			{
				return;
			}
		}
	}
	var iL=bn.createElement("link"),
	aEE=GelTags("link",bn);
	iL.type="text/css";
	iL.rel="stylesheet";
	iL.href=kt;
	if(aEE.length>0)
	{
		var aLX=aEE[aEE.length-1];
		aLX.parentNode.insertBefore(iL,
		aLX.nextSibling);
	}
	else
	{
		(GelTags("head",bn)[0]||bn.documentElement).appendChild(iQ);
	}
	return 	iL;
}


function replaceCssFile(pj,kt,gs)
{
	if(pj)
	{
		E(GelTags("link",gs||document),function(ayn)
		{
			if(ayn&&ayn.href.indexOf(pj)!=-1)
			{
				removeSelf(ayn);
			}
		});
	}
	return loadCssFile(kt,false,gs);
}


function isshowMsg()
{
	return getTop().isShow("msgBoxDIV");
}

function hiddenMsg()
{
	if(getTop().gMsgBoxTimer)
	{
		getTop().clearInterval(getTop().gMsgBoxTimer);
		getTop().gMsgBoxTimer=null;
	}
	getTop().show("msgBoxDIV",false);
	getTop().showProcess(0);
}

function showMsg()
{
	getTop().show("msgBoxDIV",true);
}


function showError(ky,kp)
{
	msgBox(ky,"",kp!=-1,kp||5000);
}


function showInfo(auN,kp)
{
	msgBox(auN,"success",kp!=-1,kp||5000);
}


function showProcess(lB,aAF,Gw,YI,avp)
{
	var aL="load_process",
	Sl=arguments.callee.aHs(aL);
	if(lB==0)
	{
		return show(Sl,false);
	}
	hiddenMsg();
	show(Sl,true);
	var sq=lB==2;
	if(sq)
	{
		if(YI)
		{
			S(aL+"_plan_info",getTop()).innerHTML=YI+":";
		}
		var iX=parseInt(Gw);
		if(isNaN(iX))
		{
			iX=0;
		}
		else
		{
			iX=Math.max(0,Math.min(100,iX));
		}
		S(aL+"_plan_rate",getTop()).innerHTML=
		S(aL+"_plan_bar",getTop()).style.width=[iX,"%"].join("");
	}
	else
	{
		if(Gw)
		{
			S(aL+"_info",getTop()).innerHTML=Gw;
		}
	}
	show(S(aL+"_plan",getTop()),sq);
	show(S(aL+"_img",getTop()),sq?false:aAF);
	show(S(aL+"_plan_info",getTop()),sq);
	show(S(aL+"_plan_rate",getTop()),sq);
	show(S(aL+"_info",getTop()),!sq);
	show(S(aL+"_cancel",getTop()),avp!=false);
}


showProcess.aHs=function(ak)
{
	var IX=S(ak,getTop());
	if(!IX)
	{
		insertHTML(
		getTop().document.body,
		"afterBegin",
		T([
		'<table id="$id$" cellspacing=0 cellpadding=0 border=0 ',
		'style="position:absolute;top:$top$px;left:0;width:100%;display:none;">',
		'<tr><td align="center">',
		'<table cellspacing=0 cellpadding=0 border=0 class="autosave autosave_txt" style="height:20px;"><tr>',
		'<td style="width:2px;"></td>',
		'<td id="$id$_img" style="padding:0 0 0 5px;">',
		'<img src="$image_path$ico_loading.gif" style="width:16px;height:16px;vertical-align:middle;">',
		'</td>',
		'<td id="$id$_plan" valign=center style="padding:0 0 0 5px;">',
		'<div style="font:1px;border:1px solid white;width:104px;text-align:left;">',
		'<div id="$id$_plan_bar" style="font:1px;background:#fff;height:8px;margin:1px 0;width:50%;"></div>',
		'</div>',
		'</td>',
		'<td id="$id$_plan_info" style="padding:0 0 0 5px;"></td>',
		'<td id="$id$_plan_rate" style="width:40px;text-align:right;padding:0;"></td>',
		'<td id="$id$_info" style="padding:0 0 0 5px;"></td>',
		'<td id="$id$_cancel" style="padding:0 0 0 5px;">',
		'[<a onclick="getTop().cancelDoSend();" nocheck="true" style="color:white;">取消</a>]',
		'</td>',
		'<td style="padding:0 0 0 5px;"></td>',
		'<td style="width:2px;"></td>',
		'</tr></table>',
		'</td></tr>',
		'</table>'
		]).replace(
		{
			id:ak,
			top:getTop().bnewwin?0:45,
			image_path:getPath("image",true)
		}
		)
		);
		IX=S(ak,getTop());
	}
	return IX;
}


function getProcessInfo()
{
	var aL="load_process",
	zq=getTop();
	return"";
}

function getTop()
{
	var te=arguments.callee;
	if(!te.Go)
	{
		try
		{
			if(window!=parent)
			{
				te.Go=parent.getTop?parent.getTop():parent.parent.getTop();
			}
			else
			{
				te.Go=window;
			}
		}
		catch(aH)
		{
			te.Go=window;
		}
	}

	return te.Go;
}

try
{
	window.top=getTop();
}
catch(aH)
{
	eval("var top = getTop();");
}
function GelTags(np,aI)
{
	var JJ=(aI||document).getElementsByTagName(np);
	if(JJ)
	{
		JJ[aDc]=true;
	}
	return JJ;
}
function S(ak,bI)
{
	try
	{
		return(bI&&(bI.document||bI)
		||document).getElementById(ak);
	}
	catch(aH)
	{
		return null;
	}
}
function E(QZ,agS,bgr,Pv)
{
	if(!QZ)
	{
		return;
	}
	
	if(QZ.length!=null)
	{
		var at=QZ.length,
		ij;
		if(Pv<0)
		{
			ij=at+Pv;
		}
		else
		{
			ij=Pv<at?Pv:at;
		}
		for(var i=(bgr||0);i<ij;i++)
		{
			try
			{
				if(agS(QZ[i],i,at)===false)
				{
					break;
				}
			}
			catch(aH)
			{
				debug([aH.message,"<br>line:",aH.lineNumber,'<br>file:',aH.fileName,"<br>",agS]);
			}
		}
	}
	else
	{
		for(var i in QZ)
		{
			try
			{
				if(agS(QZ[i],i)===false)
				{
					break;
				}
			}
			catch(aH)
			{
				debug([aH.message,"<br>",agS],61882714);
			}
		}
	}
}

/**
 * 获取当前URL地址的
 */
function GetQueryObject(){
	var url = location.href;
	var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
	var paraObj = {};
	for (i=0; j=paraString[i]; i++){
		paraObj[j.substring(0,j.indexOf("="))] = j.substring(j.indexOf("=")+1,j.length);
	}
	if(typeof(paraObj)=="undefined"){
		return "";
	}else{
		return paraObj; 
	}
}
/**
 * 获取没有分页信息的URL地址
 * @returns
 */
function GetNoPageUrl(){
	var url = location.href;
	if(url.indexOf("?")>0)
		url = url.substring(0, url.indexOf("?"));
	var queryObject = GetQueryObject();
	if(queryObject=="")
		return url;
	
	for(var item in queryObject){
		if(item=="" || ignore(item))
			continue;
		if(url.indexOf("?")>0)
			url += "&";
		else
			url += "?";
		url += item+"="+queryObject[item];
	}
	return url;
}
/**
 * 忽略分页特有参数
 * @param key
 * @returns {Boolean}
 */
function ignore(key){
	if(key=="page.pageNo")
		return true;
	if("page.pageSize"==key){
		return true;
	}
	if("page.orderBy"==key){
		return true;
	}
	if("page.order"==key){
		return true;
	}
	return false;
}
/**
 * 过滤url地址以?,&结束的字符
 * @param url
 */
function filterUrl(url){
	if(url.indexOf("?")==url.length-1 || url.indexOf("&")==url.length-1)
		return url.substring(0,url.length-1);
	return url;
}
//判断是否是整数
function IsInt(str){
	if (str==""){
	return false;
	}
	if (parseInt(str)==NaN || isNaN(str)){
		return false;
	}
	return true;
}